import java.util.ArrayList;
import java.util.List;

public class WeatherSensor {
    private final List<SensorObserver> observers = new ArrayList<>();
    private double temperature = 25.0; // 默认温度
    private double humidity = 60.0;    // 默认湿度
    private double windSpeed = 5.0;    // 默认风速

    public void addObserver(SensorObserver observer) {
        observers.add(observer);
    }

    public void setWeatherData(double temperature, double humidity, double windSpeed) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.windSpeed = windSpeed;
        notifyObservers();
    }

    private void notifyObservers() {
        for (SensorObserver observer : observers) {
            observer.updateWeather(temperature, humidity, windSpeed);
        }
    }

    public double getTemperature() {
        return temperature;
    }

    public double getHumidity() {
        return humidity;
    }

    public double getWindSpeed() {
        return windSpeed;
    }
}
